<?php

class Content_PictureController extends Areal_Controller_Action
{
    public function promoteAction()
    {
        $picture_id = $this->getRequest()->getParam('picture_id');
        $picture = Doctrine::getTable('Content_Model_Picture')->find($picture_id);
        $picture->promote();
        return $this->_helper->redirector('edit','album','content',
                                                  array('album_id'=>$picture['album_id']));
    }

    public function demoteAction()
    {
        $picture_id = $this->getRequest()->getParam('picture_id');
        $picture = Doctrine::getTable('Content_Model_Picture')->find($picture_id);
        $picture->demote();
        return $this->_helper->redirector('edit','album','content',
                                                  array('album_id'=>$picture['album_id']));
    }

    public function deleteAction()
    {
        $picture_id = $this->getRequest()->getParam('picture_id');
        $picture = Doctrine::getTable('Content_Model_Picture')->find($picture_id);
        $form = new Default_Form_ConfirmForm();
        if ($this->getRequest()->isPost()){
            if ($form->isValid($this->getRequest()->getPost())){
                $picture->delete();
                $message = Zend_Registry::get('Zend_Translate')->translate('Picture deleted');
                $this->getHelper('flashMessenger')->addMessage($message);
                return $this->_helper->redirector('edit', 'album', 'content',
                       array('album_id'=>$picture->album_id));
            }
        }
        $this->view->form = $form;
    }

}